package com.dys.databindingstudy.databinding;


import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import com.dys.databindingstudy.R;
import com.dys.databindingstudy.bean.Account;

public class DataBindingActivity extends AppCompatActivity {

    private Account account;

    private ActivityDatabindingBinding binding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_databinding);
        account=new Account();
        account.setName("TestAccount");
        account.setLevel(100);
        binding.setAccount(account);
        binding.setActivity(this);
    }

    public void onClick(View v){
        // Toast.makeText(this,"点击了",Toast.LENGTH_SHORT).show();
        int level = account.getLevel();
        account.setLevel(level+1);
        // binding.setAccount(account);
    }
}
